package com.sthz.facepay.mapper;

import com.sthz.facepay.model.Shareprofi;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.apache.ibatis.type.JdbcType;

public interface ShareprofiMapper {
    @Delete({
        "delete from st_shareprofit",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into st_shareprofit (id, aid, ",
        "pay_method, external_serial_numbe, ",
        "inside_serial_numbe, order_money, ",
        "rate, agent_profit, ",
        "pay_time, state, ",
        "agent_income, order_numebr, ",
        "platform_numebr)",
        "values (#{id,jdbcType=INTEGER}, #{aid,jdbcType=INTEGER}, ",
        "#{pay_method,jdbcType=VARCHAR}, #{external_serial_numbe,jdbcType=VARCHAR}, ",
        "#{inside_serial_numbe,jdbcType=VARCHAR}, #{order_money,jdbcType=DOUBLE}, ",
        "#{rate,jdbcType=INTEGER}, #{agent_profit,jdbcType=VARCHAR}, ",
        "#{pay_time,jdbcType=TIMESTAMP}, #{state,jdbcType=TINYINT}, ",
        "#{agent_income,jdbcType=DOUBLE}, #{order_numebr,jdbcType=VARCHAR}, ",
        "#{platform_numebr,jdbcType=VARCHAR})"
    })
    int insert(Shareprofi record);

    @InsertProvider(type=ShareprofiSqlProvider.class, method="insertSelective")
    int insertSelective(Shareprofi record);

    @Select({
        "select",
        "id, aid, pay_method, external_serial_numbe, inside_serial_numbe, order_money, ",
        "rate, agent_profit, pay_time, state, agent_income, order_numebr, platform_numebr",
        "from st_shareprofit",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="aid", property="aid", jdbcType=JdbcType.INTEGER),
        @Result(column="pay_method", property="pay_method", jdbcType=JdbcType.VARCHAR),
        @Result(column="external_serial_numbe", property="external_serial_numbe", jdbcType=JdbcType.VARCHAR),
        @Result(column="inside_serial_numbe", property="inside_serial_numbe", jdbcType=JdbcType.VARCHAR),
        @Result(column="order_money", property="order_money", jdbcType=JdbcType.DOUBLE),
        @Result(column="rate", property="rate", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_profit", property="agent_profit", jdbcType=JdbcType.VARCHAR),
        @Result(column="pay_time", property="pay_time", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="state", property="state", jdbcType=JdbcType.TINYINT),
        @Result(column="agent_income", property="agent_income", jdbcType=JdbcType.DOUBLE),
        @Result(column="order_numebr", property="order_numebr", jdbcType=JdbcType.VARCHAR),
        @Result(column="platform_numebr", property="platform_numebr", jdbcType=JdbcType.VARCHAR),
        @Result(column="aid", property="Agent", one=@One(select="com.sthz.facepay.mapper.AgentMapper.getById",fetchType = FetchType.EAGER))
    })
    Shareprofi selectByPrimaryKey(Integer id);

    @UpdateProvider(type=ShareprofiSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Shareprofi record);

    @Update({
        "update st_shareprofit",
        "set aid = #{aid,jdbcType=INTEGER},",
          "pay_method = #{pay_method,jdbcType=VARCHAR},",
          "external_serial_numbe = #{external_serial_numbe,jdbcType=VARCHAR},",
          "inside_serial_numbe = #{inside_serial_numbe,jdbcType=VARCHAR},",
          "order_money = #{order_money,jdbcType=DOUBLE},",
          "rate = #{rate,jdbcType=INTEGER},",
          "agent_profit = #{agent_profit,jdbcType=VARCHAR},",
          "pay_time = #{pay_time,jdbcType=TIMESTAMP},",
          "state = #{state,jdbcType=TINYINT},",
          "agent_income = #{agent_income,jdbcType=DOUBLE},",
          "order_numebr = #{order_numebr,jdbcType=VARCHAR},",
          "platform_numebr = #{platform_numebr,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Shareprofi record);
}